#include "Reservation.h"
#include <sstream>

Reservation::Reservation() : isCheckedIn(false) {}

Reservation Reservation::fromString(const std::string& line) {
	Reservation r;
	std::istringstream iss(line);
	std::getline(iss, r.orderId, '|');
	std::getline(iss, r.guestName, '|');
	std::getline(iss, r.idCard, '|');
	std::getline(iss, r.roomType, '|');
	std::getline(iss, r.checkInDate, '|');
	std::getline(iss, r.checkOutDate, '|');
	std::string checkedStr;
	std::getline(iss, checkedStr);
	r.isCheckedIn = (checkedStr == "1");
	return r;
}

std::string Reservation::toString() const {
	return orderId + "|" + guestName + "|" + idCard + "|" +
	roomType + "|" + checkInDate + "|" + checkOutDate + "|" +
	(isCheckedIn ? "1" : "0");
}
